

window.onload = async function (){
    init();
};

async function init() {
    var sale = await ajaxGet("/order/findAll",{
        year:select()
    });

    let label = new Array();
    let data = new Array();

    for (let i = 0; i < sale.length; i++) {
        let saleElement = sale[i];
        label[i] = saleElement.month;
        data[i] = saleElement.money;
    }


    var ctx = document.getElementById('myChart').getContext('2d');
    var chart = new Chart(ctx, {
        // 要创建的图表类型
        type: 'line',

        // 数据集
        data: {
            labels: label,
            datasets: [{
                label: "销售额",
                backgroundColor: 'rgb(255, 99, 132)',
                borderColor: 'rgb(255, 99, 132)',
                data: data,
            }]
        },

        // 配置选项
        options: {}
    });
}

function select() {
    let index = $("time").selectedIndex;
    let value = $("time").options[index].value;
    return value;
}



































